/* Compass Example

This is an example of using the HMC6352 Compass object library

Typing any key outputs the compass data

*/

#include <Wire.h>;
#include <Compass.h>

Compass compass;

void setup() {
  // Join I2C Bus
  Wire.begin();
  // Initialize serial communication 
  Serial.begin(9600);
  
  // Initialize the compass
  compass.begin();
}

void loop() {
  
  if (Serial.available()) {
    char inByte = Serial.read();
    
    // Read the compass heading
    int heading = compass.heading();
    
    // Display heading as ddd.d
    int h_10 = heading / 10;
    Serial.print("Heading = ");
    Serial.print(h_10);
    Serial.print(".");
    Serial.println(heading - (h_10 * 10));
  }
}
